<template>
    <div>
        <fieldset>
            <legend>prop、$emit父子传值</legend>
            <h1>我是父组件father------66666</h1>
            <!--        <son :messages="parentMessages">我是子组件son</son>-->
            <h3>子组件向父组件传的值为:{{fromSonMessages}}</h3>
            <son :messages="parentMessages" @listen="fromSon">我是子组件son</son>
        </fieldset>

        <fieldset>
            <legend>ref及$refs的使用</legend>
            <div class="pp" @click="show">
                <children ref="children"></children>
            </div>
        </fieldset>

    </div>
</template>

<script>
    import son from './son'
    import children from './children'
    export default {
        name: "father",
        data(){
          return{
              parentMessages: 10086,
              fromSonMessages:''
          }
        },
        methods:{
            fromSon(data){
                console.log('向父组件传的值为:'+data)
                this.fromSonMessages=data
            },
            show(){
                this.$refs.children
                this.$refs.children.changeMsg()
            },
        },
        components:{
            son,
            children,
        }
    }
</script>

<style scoped>

</style>